
// INCLUDES ********************************************************************

#include "Rectangle.h"


// NAMESPACES ******************************************************************


#pragma mark -
#pragma mark Constructors
// -----------------------------------------------------------------------------

Meteor::Rectangle::Rectangle()

: mX( 0.0f), mY( 0.0f), mWidth( 0.0f), mHeight( 0.0f)
{
}

// -----------------------------------------------------------------------------

Meteor::Rectangle::Rectangle( const float x,
                      const float y, 
                      const float width, 
                      const float height)

: mX( x), mY( y), mWidth( width), mHeight( height)
{
}

// -----------------------------------------------------------------------------

Meteor::Rectangle::Rectangle( const Rectangle& rhs)
{
    if ( this == &rhs)
    {
        return;
    }
}

// -----------------------------------------------------------------------------

Meteor::Rectangle& Meteor::Rectangle::operator=( const Meteor::Rectangle& rhs)
{
    if ( this == &rhs)
    {
        return *this;
    }
    
    mX = rhs.X();
    mY = rhs.Y();
    
    mWidth = rhs.Width();
    mHeight = rhs.Height();
    
    return *this;
}

// -----------------------------------------------------------------------------

Meteor::Rectangle::~Rectangle()
{
}

#pragma mark -
#pragma mark Geometric operations
// -----------------------------------------------------------------------------

const bool Meteor::Rectangle::Contains( const Meteor::Vector2D& vector) const
{
    if ( vector.X() >= mX &&
         vector.Y() >= mY &&
         vector.X() <= mX + mWidth &&
         vector.Y() <= mY + mHeight)
    {
        return true;
    } 
    else
    {
        return false;
    }
}

#pragma mark -
#pragma mark Getter
// -----------------------------------------------------------------------------

const float Meteor::Rectangle::X() const
{
    return mX;
}

// -----------------------------------------------------------------------------

const float Meteor::Rectangle::Y() const
{
    return mY;
}

// -----------------------------------------------------------------------------

const float Meteor::Rectangle::Width() const
{
    return mWidth;
}

// -----------------------------------------------------------------------------

const float Meteor::Rectangle::Height() const
{
    return mHeight;
}

#pragma mark -
#pragma mark Setter
// -----------------------------------------------------------------------------

void Meteor::Rectangle::SetX( const float newX)
{
    mX = newX;
}

// -----------------------------------------------------------------------------

void Meteor::Rectangle::SetY( const float newY)
{
    mY = newY;
}

// -----------------------------------------------------------------------------

void Meteor::Rectangle::SetWidth( const float newWidth)
{
    mWidth = newWidth;
    
    if ( mWidth < 0.0f)
    {
        mWidth = 0.0f;
    }
}

// -----------------------------------------------------------------------------

void Meteor::Rectangle::SetHeight( const float newHeight)
{
    mHeight = newHeight;
    
    if ( mHeight < 0.0f)
    {
        mHeight = 0.0f;
    }
}

